package xyz.liut.autolaunch;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * Create by liut on 20-10-27
 */
public class IoUtils {


    /**
     * 把流转化为字符串String类型的工具类
     */
    public static String stream2String(InputStream is) throws IOException {
        if (is != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            byte[] buffer = new byte[1024];
            int temp;
            while ((temp = is.read(buffer)) != -1) {
                baos.write(buffer, 0, temp);
            }
            is.close();
            baos.close();
            return baos.toString();
        }
        return null;
    }

}
